package com.aofeng.hybrid.util;

import com.af.expression.Delegate;
import com.af.expression.Program;

import java.util.Map;

/**
 * 表达式运行
 * Created by LGY on 2016-07-04.
 */
public class ExpressionHelper {
    /**
     * 带参运行表达式
     * @param source: 表达式源码
     * @param params: 表达式参数
     * @return: 表达式运行结果
     */
    public static Object run(String source, Map<String, Object> params) {
        Program prog = new Program(source);
        // 解析
        Delegate d = prog.parse();
        Object result = d.invoke(params);
        return result;
    }

}
